package snippet;

import java.io.FileNotFoundException;
import java.io.PrintStream;

class CSVSaver {
	public static final String DEFAULT_SEPARATOR = ",";
	//not fully implemented
	double[][] data;
	public CSVSaver(double[][] data) {
		this.data=data;
	}
	public void save(String filemame) throws FileNotFoundException {
		save(new PrintStream(filemame));
	}
	public void save(PrintStream pStream) {
		for(double[] row:this.data){
			int col;
			for(col=0;col<row.length-1;col++){
				pStream.print((Double.isNaN(row[col])?"NA":row[col])+DEFAULT_SEPARATOR);
			}
			pStream.println(Double.isNaN(row[col])?"NA":row[col]);
		}
	}
}
